use "build/output/main_panel.dta", clear

tsset coin_id bcaldate

gen d_margin_aprFTX = d.margin_aprFTX
gen d_y_effr = d.y_effr

label var y_effr "\$\text{EFFR}_{t}\$"
label var d_y_effr "\$\Delta\text{EFFR}_{t}\$"

eststo clear

eststo: estpost corr d_y_effr d_margin_aprFTX if coin == "USDT"
corr d_y_effr d_margin_aprFTX if coin == "USDT"
estadd scalar N = `r(N)', replace

eststo: estpost corr d_y_effr d_margin_aprFTX if coin == "DAI"
corr d_y_effr d_margin_aprFTX if coin == "DAI"
estadd scalar N = `r(N)', replace
esttab
esttab using "analysis/output_tables/table_lending_rate_correlation.tex", nonote label replace star(* 0.10 ** 0.05 *** 0.01) p(2) b(3) prehead({\begin{tabular}{l S S} \toprule) ///
	posthead(\midrule) ///
	mgroups("USDT" "DAI", pattern(1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	stats(N, fmt(%12.0fc 2) layout("\multicolumn{1}{c}{@}") labels(`"\$N\$"')) ///
	varlabels(margin_aprFTX "\$R_{i,t}\$" d_margin_aprFTX "\$\Delta R_{i,t}\$") nonumbers  style(tex) substitute(\_ _) booktabs 
